package com.xf.pub.exception;

import com.xf.pub.exception.base.ExceptionFrameWorkResource;
import com.xf.pub.exception.base.ExceptionResource;

public class ExceptionMessageFactory
{
  private static ExceptionFrameWorkResource appResource;
  private static ExceptionResource customerResource;

  ExceptionMessageFactory(boolean isDefault, String path)
  {
    if (isDefault)
      appResource = new ExceptionFrameWorkResource();
    else
      customerResource = new ExceptionResource(path);
  }

  public static ExceptionMessageFactory getInstance(boolean isDefault, String path)
  {
    return new ExceptionMessageFactory(isDefault, path);
  }

  public static String getExceptionMessage(String Key)
  {
    if (appResource != null)
      return ExceptionFrameWorkResource.getFrameWorkMessage(Key);
    if (customerResource != null)
      return ExceptionResource.getExceptionMessage(Key);

    return "";
  }

  public static String getExceptionMessage(String Key, String Default)
  {
    if (appResource != null)
      return ExceptionFrameWorkResource.getFrameWorkMessage(Key, Default);
    if (customerResource != null)
      return ExceptionResource.getExceptionMessage(Key, Default);

    return "";
  }
}